﻿using JinianNet.JNTemplate;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using My.Admin.Dto.System;
using My.Admin.Enum;
using My.Admin.Model.System;
using My.Admin.Service.System.IService;
using My.Core.DynamicWebApi.Attributes;
using System.ComponentModel;

namespace My.Admin.Dynamic
{
	[Service("SysMenuController")]
	public class SysMenuController
	{
		private readonly ISysMenuService _sysMenuRep;

		public SysMenuController(ISysMenuService sysMenuRep)
		{
			_sysMenuRep = sysMenuRep;
		}

		/// <summary>
		/// 获取登录菜单树
		/// </summary>
		/// <returns></returns>
		[Authorize]
		public async Task<List<MenuOutput>> QuerySysMenu()
		{
			return await _sysMenuRep.QuerySysMenu();
		}

		/// <summary>
		/// 获取菜单列表
		/// </summary>
		/// <returns></returns>
		[Authorize]
		public async Task<List<SysMenu>> GetList([FromQuery] MenuInput input)
		{
			return await _sysMenuRep.GetList(input);
		}

		/// <summary>
		/// 删除菜单
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task DeleteMenu(DeleteMenuInput input)
		{
			 await _sysMenuRep.DeleteMenu(input);
		}

		/// <summary>
		/// 增加菜单
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task AddMenu(AddMenuInput input)
		{
			await _sysMenuRep.AddMenu(input);
		}

		/// <summary>
		/// 更新菜单
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task UpdateMenu(UpdateMenuInput input)
		{
			await _sysMenuRep.UpdateMenu(input);
		}
	}
}
